package com.xinzhi.service.impl;

import com.baomidou.mybatisplus.extension.api.R;
import com.xinzhi.mapper.UserMapper;
import com.xinzhi.mapper.UseroperationMapper;
import com.xinzhi.pojo.User;
import com.xinzhi.pojo.Useroperation;
import com.xinzhi.service.IUseroperationService;
import com.xinzhi.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UseroperationImpl implements IUseroperationService {
    @Autowired
    private UseroperationMapper useroperationMapper;
    @Autowired
    private UserMapper userMapper;
    @Override
    public Result getUseroperation(String phone) {
        if (phone == null || phone.equals("")) {
            return Result.error("手机号不能为空");
        }
        User selectid = userMapper.selectid(phone);
        if (selectid == null)
            return Result.error("没有该用户");
        Useroperation all = useroperationMapper.getAll(selectid.getId());
        return  all!=null ? Result.ok(all.getOperationtime()): Result.error("没有操作记录");
    }
}
